# -*- coding:utf-8 -*-
#list = [100,80,120,200,50]
list = [100,80,120]


def buddle_sort(list):
    for i in range(0, len(list)):
        for j in range(0, len(list) - i - 1):
            if list[j] > list[j+1]:
                temp = list[j]
                list[j] = list[j+1]
                list[j+1] = temp

#buddle_sort(list)



def select_sort(list):
    for i in range(0, len(list)):
        min = list[i]
        minIndex = i
        for j in range(i, len(list)):
            if list[j] < min:
                min = list[j]
                minIndex = j
        if minIndex != i:
            temp = list[i]
            list[i] = list[minIndex]
            list[minIndex] = temp
            
#select_sort(list)

def insert_sort(list):
    for i in range(0, len(list)):
        j = 1
        for j in range(1, len(list)):
            if list[j] < list[j-1]:
                temp = list[j]
                list[j] = list[j-1]
                list[j-1] = temp
#insert_sort(list)

def merge_sort(list, left, right):
    if left < right:
        mid = (left + right) // 2 
        merge_sort(list, left, mid)
        merge_sort(list, mid + 1, right)
        merge(list, left, mid, right)

def merge(list, left, mid, right):
    i, j = left, mid + 1
    temp = []
    while (i <= mid) and j <= right:
        if list[i] > list[j]:
            temp.append(list[j])
            j = j + 1
        else:
            temp.append(list[i])
            i = i + 1


    while i <= mid:
        temp.append(list[i])
        i = i + 1
    while j <= right:
        temp.append(list[j])
        j = j + 1

    k = left
    i = 0
    for k in range(left, left + len(temp)):
        list[k] = temp[i]
        i = i + 1

#merge_sort(list, 0, len(list) - 1)

def quick_sort(list, low, high):
    if low < high:
        middle = get_middle(list, low, high)
        quick_sort(list, low, middle - 1)
        quick_sort(list, middle + 1, high)

def get_middle(list, low, high):
    temp = list[low]
    while low < high:
        while low < high and list[high] >= temp:
            high = high - 1
        list[low] = list[high]
        while low < high and list[low] <= temp:
            low = low + 1
        list[high] = list[low]
    list[low] = temp
    return low

quick_sort(list, 0, len(list) - 1)
print(list)
    



